<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>拖拽插件</title>
    <style>
        #dragbox{
            position: absolute;
            top:200px;
            width:400px;
            height:450px;
            border:1px solid #eee;
            -webkit-box-shadow: 0 0 4px rgb(0,0,0);
            -moz-box-shadow: 0 0 4px rgb(0,0,0);
            box-shadow: 0 0 4px rgb(0,0,0);
        }
        #tittle{
            height:50px;
            line-height:50px;
            text-align: center;
            background-color: yellow;
            cursor: move;
        }
        .body{
            height:400px;
            -webkit-box-sizing: border-box;
            -moz-box-sizing: border-box;
            box-sizing: border-box;
            padding:60px;
        }
    </style>
</head>
<body>
<div>
    <div id="dragbox">
        <div id="tittle">
            点击标题拖拽
        </div>
        <div class="body">
            被拖拽的#dragbox需要相对定位\绝对定位
        </div>
    </div>
</div>
<script src="drag.js"></script>
<script>
    //拖拽
    var oBar = document.getElementById("tittle");
    var oBox = document.getElementById("dragbox");
    oBox.style.left = document.body.clientWidth/2 - oBox.clientWidth /2 + 'px';
    startDrag(oBar, oBox);
</script>
</body>
</html>